import request from '@/config/request.js'
import { getTenantId } from '@/utils/auth'

// 获取设备信息
export const getDeviceInfo = (data) => {
  return request.get('/app-api/system/app/common/getDeviceInfo', data, {
    header: {
      'content-type': 'application/json'
    }
  })
}

// 根据租户名搜索租户列表
export const getTenantListByName = (params) => {
  return request.get('/app-api/system/app/tenant/getTenantListByName', params, {
    header: {
      'content-type': 'application/json',
      'tenant-id': ''
    }
  })
}

// 登录
export const Login = async (data) => {
  const { tenantId, username, password } = data

  return request.post(
    '/app-api/system/app/auth/login',
    { username, password },
    {
      header: {
        'content-type': 'application/json',
        'tenant-id': tenantId || (await getTenantId())
      }
    }
  )
}
